import { PACK_SOURCE_TYPES } from '../types/types'

let rootURI: string
const host: string = '106.14.28.252'
// const host: string = '192.168.31.15'
// const host: string = '127.0.0.1'

const isDev = () => (import.meta as any).env.DEV === true


const URL_MAP = {
  'dcm4chee': `http://${host}:8080/dcm4chee-arc/aets/DCM4CHEE/rs`,
  'orthanc': `http://${host}:8042`, // 阿里云
  'official': 'https://d3t6nz73ql33tx.cloudfront.net/dicomweb'
}


const PACS_SETTING = {
  OpenAuth: true,
  username: 'admin',
  password: '123456',
  PACS_SOURCE: 'orthanc' as PACK_SOURCE_TYPES
}

rootURI = URL_MAP[PACS_SETTING.PACS_SOURCE]

const getDicomSource = () => {
  // pro 环境,设置的图像是：阿里云上的320张方形模体。
  return {
    StudyInstanceUID: '1.2.826.0.1.3680043.2.461.13044537.2800407881',
    SeriesInstanceUID: '1.2.840.113619.2.472.3.2831161356.403.1654067940.232.6295553',
    wadoRsRoot: '/dicom-web'
  }
  if (!isDev()) {
    return {
      StudyInstanceUID: '1.2.826.0.1.3680043.2.461.13044537.2800407881',
      SeriesInstanceUID: '1.2.840.113619.2.472.3.2831161356.403.1654067940.232.6295553',
      wadoRsRoot: rootURI + '/dicom-web'
    }
  }
  let params

  switch (PACS_SETTING.PACS_SOURCE) {
    case 'official':
      params = {
        StudyInstanceUID:
          '1.3.6.1.4.1.14519.5.2.1.7009.2403.334240657131972136850343327463',
        SeriesInstanceUID:
          '1.3.6.1.4.1.14519.5.2.1.7009.2403.226151125820845824875394858561',
        wadoRsRoot: getRootUrl()
      }
      break
    case 'dcm4chee':
      params = {
        StudyInstanceUID: '1.2.826.0.1.3680043.2.461.13044537.2800407881',
        SeriesInstanceUID: '1.2.840.113619.2.472.3.2831161356.403.1654067940.232.6295553',
        wadoRsRoot: getRootUrl()
      }
      break
    case 'orthanc':
      params = {
        StudyInstanceUID: '1.2.826.0.1.3680043.2.461.13044537.2800407881',
        SeriesInstanceUID: '1.2.840.113619.2.472.3.2831161356.403.1654067940.232.6295553',
        wadoRsRoot: getRootUrl()
      }
      break
    default:
      break
  }
  return params
}

const getRootUrl = () => {
  let routerPath
  if (isDev()) {
    routerPath = '/dicom-web'
  } else {
    routerPath = rootURI + '/dicom-web'
  }
  console.log(`router path: ${routerPath}`)
  return routerPath
}

const PACS = {
  root: rootURI,
  wadoURIRoot: `${rootURI}`
}


export {
  PACS,
  getDicomSource,
  PACS_SETTING,
  isDev
}
